package com.ruoyi.web.dorm.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.dorm.entity.AdminEntity;
import com.ruoyi.web.dorm.mapper.AdminMapper;
import com.ruoyi.web.dorm.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    /**
     * 我的桌面 获取管理员个人信息
     * @param adminEntity
     * @return
     */
    @Override
    public List<AdminEntity> TabAdminList(AdminEntity adminEntity) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        adminEntity.setUserId(userId);
        return adminMapper.getAdminList(adminEntity);
    }
    //查询管理员列表
    @Override
    public List<AdminEntity> getAdminList(AdminEntity adminEntity) {
        return adminMapper.getAdminList(adminEntity);
    }


    //    添加管理员
    @Override
    public int addAdminList(AdminEntity adminEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取修改人的名字 添加进去
        adminEntity.setCreateBy(username);
        return adminMapper.addAdminList(adminEntity);
    }

    @Override
    public int updateAdminList(AdminEntity adminEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取修改人的名字 添加进去
        adminEntity.setUpdateBy(username);
        return adminMapper.updateAdminList(adminEntity);
    }

    @Override
    public int delAdminList(Long id) {
        return adminMapper.delAdminList(id);
    }







}
